Testcase is attached.
#include "gtkintl.h"
#include "gtkprivate.h"
#include "gtktypebuiltins.h"
+#include "gtkcssshadowsvalueprivate.h"
+#include "gtkstylecontextprivate.h"
+#include "gtkwidgetprivate.h"
#include "a11y/gtkimageaccessible.h"
#define DEFAULT_ICON_SIZE GTK_ICON_SIZE_BUTTON
static gint gtk_image_draw (GtkWidget *widget,
cairo_t *cr);
+static void gtk_image_size_allocate (GtkWidget *widget,
+ GtkAllocation*allocation);
static void gtk_image_unmap (GtkWidget *widget);
static void gtk_image_realize (GtkWidget *widget);
static void gtk_image_unrealize (GtkWidget *widget);
widget_class->get_preferred_width = gtk_image_get_preferred_width;
widget_class->get_preferred_height = gtk_image_get_preferred_height;
widget_class->get_preferred_height_and_baseline_for_width = gtk_image_get_preferred_height_and_baseline_for_width;
+ widget_class->size_allocate = gtk_image_size_allocate;
widget_class->unmap = gtk_image_unmap;
widget_class->realize = gtk_image_realize;
widget_class->unrealize = gtk_image_unrealize;
}
}
+static void
+gtk_image_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation)
+{
+ GtkBorder extents;
+ GtkAllocation clip;
+
+ GTK_WIDGET_CLASS (gtk_image_parent_class)->size_allocate (widget, allocation);
+
+ /* XXX: This is not strictly correct, we could compute the area
+ * actually occupied by the image, but I'm lazy...
+ */
+ _gtk_css_shadows_value_get_extents (_gtk_style_context_peek_property (gtk_widget_get_style_context (widget), GTK_CSS_PROPERTY_ICON_SHADOW), &extents);
+ clip.x = allocation->x - extents.left;
+ clip.width = allocation->width + extents.left + extents.right;
+ clip.y = allocation->y - extents.top;
+ clip.height = allocation->height + extents.top + extents.bottom;
+ _gtk_widget_set_simple_clip (widget, &clip);
+}
+
static void
gtk_image_unmap (GtkWidget *widget)
{
iconview-empty.css \
iconview-empty.ui \
iconview-empty.ref.ui \
+ image-icon-shadow-clipping.css \
+ image-icon-shadow-clipping.ref.ui \
+ image-icon-shadow-clipping.ui \
image-load-from-file.css \
image-load-from-file.ref.ui \
image-load-from-file.ui \
--- /dev/null
+@import "reset-to-defaults.css";
+
+GtkImage {
+ icon-shadow: 20px 20px tomato;
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.18.1 -->
+<interface>
+ <requires lib="gtk+" version="3.12"/>
+ <object class="GtkWindow" id="window1">
+ <property name="width_request">100</property>
+ <property name="height_request">100</property>
+ <property name="can_focus">False</property>
+ <property name="type">popup</property>
+ <child>
+ <object class="GtkImage" id="image1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">edit-delete</property>
+ </object>
+ </child>
+ </object>
+</interface>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.18.1 -->
+<interface>
+ <requires lib="gtk+" version="3.12"/>
+ <object class="GtkWindow" id="window1">
+ <property name="width_request">100</property>
+ <property name="height_request">100</property>
+ <property name="can_focus">False</property>
+ <property name="type">popup</property>
+ <child>
+ <object class="GtkBox" id="box2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkImage" id="image1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">edit-delete</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>